﻿<!--#include file="commond.asp" -->
<!--#include file="header.asp" -->
<!--#include file="plugins.asp" -->
<!--#include file="common/ModSet.asp" -->
<!--#include file="common/UBBconfig.asp" -->
<%
'=====================================
'  魔法表情插件信息处理页面
'    更新时间: 2006-2-9
'=====================================
'Iwill4869修改版1.1
'修改日期:2008-3-11
'修改内容:
'        1.增加魔法图片目录设置，方便多blog重用
'        2.图片按风格分目录存放并将gif和swf放在同一个目录,方便图片管理
'        3.按目录分页显示和选择,减少加载时服务器的流量和等待时间
'=====================================
function IIF(l,y,n)
	if l then
		IIF=y
	else
		IIF=n
	end if
end function

dim LoadMagicFaceModSet
Set LoadMagicFaceModSet=New ModSet
LoadMagicFaceModSet.open("MagicFace")
if not LoadMagicFaceModSet.PasreError=0 then
   showmsg "错误信息","你沒有安裝魔法表情插件<br/><a href=""javascript:history.go(-1)"">单击返回</a>","MessageIcon",""
end if

dim mfImgRoot
mfImgRoot=LoadMagicFaceModSet.getKeyValue("mfImgRoot") '获取图片根目录

Dim ACTION,mfACTION
ACTION = Request.QueryString("mfaction")
if ACTION = "" then ACTION = Request.form("mfaction")
mfACTION=ACTION

Dim ArticleID
ArticleID = CheckStr(Request.QueryString("artId"))
if ArticleID = "" then ArticleID = Request.form("artId")

Dim MFSelectRadio
MFSelectRadio = Request.QueryString("MF_Radio")
if MFSelectRadio = "" then MFSelectRadio = Request.form("MF_Radio")
if MFSelectRadio = "" then MFSelectRadio = "A_001"

Dim MFSelectTD
MFSelectTD = Request.QueryString("TD")

      Dim Article_View,ArticleAuthor
      set Article_View=Conn.ExeCute("SELECT * FROM blog_Content WHERE log_ID="&ArticleID&" and log_IsDraft=false")

      ArticleAuthor = Article_View("log_Author")
      if memName<>ArticleAuthor then
        showmsg "错误信息","非法操作！<br/><a href=""javascript:history.go(-1)"">单击返回</a>","ErrorIcon",""
      end if

if MFSelectTD = "" then 	'判断是否是切换分页
	MFSelectTD=left(MFSelectRadio,1)
	if ACTION="NEW" then mfACTION="NEWACTION"
	if ACTION="CHANGE" then mfACTION="MODIFY"
	if ACTION="NEW" then
	   showAllMF                     '新增
	elseif ACTION="NEWACTION" then 
	   newmodifyMF                   '新增的动作
	elseif ACTION="CHANGE" then 
	   showAllMF                     '修改
	elseif ACTION="MODIFY" then 
	   newmodifyMF                   '修改
	elseif ACTION="DELETE" then 
	   delMF                         '删除
	else
	   showmsg "错误信息","非法操作！<br/><a href=""javascript:history.go(-1)"">单击返回</a>","ErrorIcon",""
	end if
else
	showAllMF
end if

'============================= SHOW ALL MF ========================================
function showAllMF
%>
<script language="javascript">
function MF_TDPage(td)
{
	var obj=document.getElementById("frm2");
	obj.action=obj.action+"?TD="+td;
	obj.submit();
}
function MM_HideLayers() { //v6.0
	var obj;
	obj=document.getElementById("MagicFace");
	obj.style.visibility='hidden';
}
var MF_Timer;
function ShowMagicFace(MagicFile){
	var MagicFaceUrl= "<%=mfImgRoot%>/"+MagicFile+".swf";
	var obj = document.getElementById("MagicFace");
	try{clearTimeout(MF_Timer)}catch(e){}
	
	obj.innerHTML = '<object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="500" height="350"><param name="movie" value="'+ MagicFaceUrl +'"><param name="menu" value="false"><param name="quality" value="high"><param name="play" value="false"><param name="wmode" value="transparent"><embed src="' + MagicFaceUrl +'" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="500" height="350"></embed></object>';
	obj.style.top = (document.documentElement.scrollTop+300/2)+"px";
	obj.style.left = (document.body.scrollLeft+((document.body.clientWidth-480)/2))+"px";
	obj.style.visibility = 'visible';
	MF_Timer=setTimeout("MM_HideLayers()",5000);
}
</script>
<div id="Tbody">
<div id=MagicFace style="POSITION: absolute; z-index:100"></div>
<br/><br/>
   <div style="text-align:center;">
<form name="frm2" action="mfaction.asp" method="post" style="margin:0px;">
    <div id="MsgContent" style="width:100%">
      <div id="MsgHead">魔法表情选择</div>
      <div id="MsgBody">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr align="center" height="20px"><td colspan="12"></td></tr>
<tr align="center"><td colspan="12" align="center"><B>选择表情分类</B></td></tr>
<%
Dim oMFfso,oMFImgroot,i,filename
set oMFfso=server.CreateObject("scripting.filesystemobject")
set oMFImgroot=oMFfso.GetFolder(server.MapPath(mfImgRoot))
'枚举目录
dim oMFdir,oMFdirs
set oMFdirs=oMFImgroot.Subfolders
i=1
for each oMFdir in oMFdirs
	if (i mod 12)=1 then Response.write "<tr height=60>"
	filename=mfImgRoot&"/"&oMFdir.name&"/mf_"&oMFdir.name&"_001.gif"
%>
    <td width=40>
        <%=oMFdir.name%><br>
        <a href="javascript:MF_TDPage('<%=oMFdir.name%>');"><img src="<%=filename%>" border="0"></a>
    </td>
<%
	if (i mod 12)=0 then Response.write "</tr>"
	i=i+1
next
Response.write "</tr>"
set oMFdirs=nothing
set oMFdir=nothing
%>
<tr align="center" height="20px"><td colspan="12"></td></tr>
<tr align="center"><td colspan="12" align="center"><B>选择表情</B></td></tr>
<%
'枚举文件
Dim oMFfile,oMFfiles,temp
set oMFImgroot=oMFfso.GetFolder(server.MapPath(mfImgRoot&"/"&MFSelectTD))
set oMFfiles=oMFImgroot.Files
i=1
for each oMFfile in oMFfiles
	if lcase(oMFfso.GetExtensionName(oMFfile.name))="swf" and len(oMFfile.name)>11 then
		temp=mid(oMFfile.name,4,len(oMFfile.name)-7)
		filename=MFSelectTD&"/MF_"&temp
		if (i mod 12)=1 then Response.write "<tr height=100>"
%>
	<td width=40>
        <%=temp%><br>
        <a href="javascript:ShowMagicFace('<%=filename%>');"><img src="<%=mfImgRoot&"/"&filename%>.gif" border="0" alt="&#28857;&#20987;&#39044;&#35272;&#34920;&#24773;"></a><br>
        <input type="Radio" name="MF_Radio" value="<%=temp%>"<%=IIF(temp=MFSelectRadio," checked","")%>/>
    </td>
<%
		if (i mod 12)=0 then Response.write "</tr>"
		i=i+1
	end if
next
Response.write "</tr>"
set oMFfile=nothing
set oMFfiles=nothing
set oMFImgroot=nothing
set oMFfso=nothing
%>
<tr align="center">
<td colspan="12" align="center">
<input name="mfaction" type="hidden" value="<%=mfACTION%>"/>
<input name="artId"  type="hidden" value="<%=ArticleID%>"/>
<input name="submitbut" type="submit" class="userbutton" value="确定"/>
<input name="pgback" type="button" class="userbutton" value="取消" onclick="document.location.href='article.asp?id=<%=ArticleID%>';"/>
</td>
</tr>
</table>


	  </div>
	</div>
</form>
  </div><br/><br/>
</div>

<%
end function
'zzw
'============================= 新增 & 更新 ========================================
function newmodifyMF
  Dim MFConn,Rsad
  
  Set MFConn= Server.CreateObject("ADODB.Connection")
  MFConn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("Plugins/Magicface/Magicface.mdb")
  MFConn.Open

  Dim MF_Content
  set MF_Content=MFConn.ExeCute("SELECT * FROM Magicface WHERE MF_Article_ID="&ArticleID&" ")
 
  if MF_Content.eof or MF_Content.bof then
         MFConn.ExeCute("INSERT INTO Magicface(MF_Article_ID,MF_Face_File) VALUES ("&ArticleID&","""&MFSelectRadio&""")")
	 showmsg "魔法表情新增","<b>你成功地新增了魔法表情</b><br/><a href=""article.asp?id="&ArticleID&" "">单击返回日志</a>","MessageIcon","" 
  else
	 MFConn.ExeCute("update Magicface set MF_Face_File="""&MFSelectRadio&""" where MF_Article_ID="&ArticleID&" ")
	 showmsg "魔法表情更新","<b>你成功地更新了魔法表情</b><br/><a href=""article.asp?id="&ArticleID&" "">单击返回日志</a>","MessageIcon","" 
  end if

  MFConn.close
  set MFConn=nothing
end function

'============================= 删除 ========================================
function delMF
  Dim MFConn
  
  Set MFConn= Server.CreateObject("ADODB.Connection")
  MFConn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("Plugins/Magicface/Magicface.mdb")
  MFConn.Open

  Dim MF_Content
  set MF_Content=MFConn.ExeCute("SELECT * FROM Magicface WHERE MF_Article_ID="&ArticleID&" ")

  if MF_Content.eof or MF_Content.bof then
     showmsg "错误信息","<b>此日志不存在魔法表情!</b><br/><a href=""javascript:history.go(-1);"">单击返回</a>","ErrorIcon",""
	 exit function
  end if

  MFConn.ExeCute("DELETE * FROM Magicface WHERE MF_Article_ID="&ArticleID&" ")
  showmsg "魔法表情删除","<b>你成功地删除了魔法表情!</b><br/><a href=""article.asp?id="&ArticleID&" "">单击返回日志</a>","MessageIcon","" 

  MFConn.close
  set MFConn=nothing
end function
%><!--#include file="footer.asp" -->